type DataGroup = {
  id: string;
  label: string;
};

export function generatorDataGroup(
  ...rest: string[]
): [DataGroup[], Record<string, string>] {
  if (!rest) {
    return [[], {}];
  }

  if (rest.length % 2 !== 0) {
    throw new Error("参数数量不匹配");
  }
  const list: DataGroup[] = [];
  const map: Record<string, string> = {};
  for (let i = 0; i < rest.length; i += 2) {
    const id = rest[i];
    const label = rest[i + 1];
    list.push({ id, label });
    Object.assign(map, { [id]: label });
  }
  return [list, map];
}
